#ifndef INCLUDE_MAIL_BOX_
#define INCLUDE_MAIL_BOX_

#include "type.h"
#include "sync.h"

#define MAX_MBOX_LENGTH (64)

typedef struct mailbox
{
    char name[20];
    char msg[MAX_MBOX_LENGTH];
    int user;
    int msg_head;
    int msg_tail;
    int left_space;

    condition_t full;
    condition_t empty;
    mutex_lock_t mutex;

} mailbox_t;


void mbox_init();
mailbox_t *mbox_open(char *);
void mbox_close(mailbox_t *);
void mbox_send(mailbox_t *, void *, int);
void mbox_recv(mailbox_t *, void *, int);

#endif